<%@ page pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<!DOCTYPE html >
<html>
<head>
    <title>后台管理</title>
    <meta charset="utf-8"/>
    <link rel="stylesheet" type="text/css" href="/css/admin.css"/>
    <script>
        window.onload = function () {
            document.getElementById("categoryId").value = '${goodsQO.categoryId}' === '' ? 0 : '${goodsQO.categoryId}'
        }

        function goPage(p){
            //将页码赋值到表单中的隐藏控件
            document.getElementById("pageNo").value=p
            //使用js提交表单
            document.getElementById("form1").submit()
        }

        function min(a,b){
            return a<b?a:b
        }
        function max(a,b){
            return a>b?a:b
        }
    </script>
</head>
<body>
<div class="container">
    <div id="header">
        <jsp:include page="header.jsp"/>
    </div>
    <div id="admin_left">
        <ul class="submenu">
            <jsp:include page="left.jsp"/>
        </ul>
        <div id="copyright"></div>
    </div>
    <div id="admin_right">
        <div class="headbar">
            <div class="searchbar">
                <form action="/admin/goods/listbypage" method="get" id="form1">
                    <input type="hidden" name="pageNo" id="pageNo" value="1">
                    <select class="auto" name="categoryId" id="categoryId">
                        <option value="0">选择分类</option>
                        <c:forEach items="${categories}" var="category">
                            <option value="${category.id}">${category.name}</option>
                        </c:forEach>
                    </select>
                    库存：<input class="small" type="text" name="minStock" value="${goodsQO.minStock}">-<input
                        class="small" type="text"
                        name="maxStock" value="${goodsQO.maxStock}">
                    商品名： <input class="small" name="name" id="name" type="text" value="${goodsQO.name}">
                    <button class="btn" type="submit">
                        <span class="sel">筛 选</span>
                    </button>
                </form>
            </div>

            <div class="field">
                <table class="list_table">
                    <col width="40px"/>
                    <col width="400px"/>
                    <col width="120px"/>
                    <col width="70px"/>
                    <col width="70px"/>
                    <col width="70px"/>
                    <col width="70px"/>
                    <thead>
                    <tr>
                        <th>选择</th>
                        <th>商品名称</th>
                        <th>商品图片</th>
                        <th>分类</th>
                        <th>销售价</th>
                        <th>库存</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <form action="" method="post" name="orderForm">
            <div class="content">
                <table class="list_table">
                    <col width="40px"/>
                    <col width="400px"/>
                    <col width="120px"/>
                    <col width="70px"/>
                    <col width="70px"/>
                    <col width="70px"/>
                    <col width="70px"/>
                    <tbody>
                    <c:forEach items="${pageBean.data}" var="goods">
                        <tr>
                            <td><input name="" type="checkbox" value=""/></td>
                            <td>${goods.name}</td>
                            <td><img src="${goods.image}" width="100" height="100"/></td>
                            <td>${goods.cname}</td>
                            <td>${goods.salePrice}</td>
                            <td>${goods.stock}</td>
                            <td><a href=""><img
                                    class="operator" src="/images/admin/icon_edit.gif" alt="编辑"/></a>
                                <a href="javascript:void(0)"><img
                                        class="operator" src="/images/admin/icon_del.gif" alt="删除"/></a></td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </form>
        <div class='pages_bar'>
            <a href='javascript:void(0)' onclick="goPage(1)" id="first">首页</a>
            <a href='javascript:void(0)' onclick="goPage(max(${pageBean.page-1},1))" id="first">上一页</a>
            <c:forEach begin="1" end="${pageBean.totalPage}" var="p">
                <a href="javascript:void(0)" onclick="goPage(${p})">${p}</a>
            </c:forEach>
            <a href='javascript:void(0)' onclick="goPage(min(${pageBean.page+1},${pageBean.totalPage}))" id="first">下一页</a>
            <a href='javascript:void(0)' onclick="goPage(${pageBean.totalPage})" id="last">尾页</a>
            <select name="" id="" onchange="goPage(this.value)">
                <c:forEach begin="1" end="${pageBean.totalPage}" var="p">
                    <option value="${p}">${p}</option>
                </c:forEach>
            </select>
            <input type="text"> <input type="submit" value="跳转">
            <span>当前第${pageBean.page}页/共${pageBean.totalPage}页，当前页有${pageBean.pageCount}条数据，一共有${pageBean.total}数据</span>
        </div>
    </div>
    <div id="separator"></div>
</div>
</body>
</html>